<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

    <ui:define name="head">
        <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
        <script type="text/javascript" language="javascript">
            document.onkeydown = function TabReplace() {
                if (event.keyCode == 13) {
                    if (event.srcElement.tagName != 'BUTTON')
                        event.keyCode = 9;
                    else
                        event.srcElement.click();
                }
            }
            function actSelect(obj,pageName) {
                var pkid=obj;
                 var sfeature = "dialogwidth:1300px;dialogheight:700px;center:yes;location:no;help:no;resizable:no;scroll:no;status:no";
                var arg = new Object();
                arg.doType = "select";
                if (pageName=="Cstpl_Detail"){
                    var rtn =dialog("../item/itemHieRelapQry_Tk_Cstpl.xhtml?strType=1&amp;strCstplPkid="+pkid+"",arg,sfeature);
                }else if(pageName=="Attachment"){
                    var rtn = window.open("/epss/servlet/ShowServlet?operType=Qry&amp;strType=0&amp;strPkid="+pkid+"",
                            'popupwindow',
                            'height = 300,width = 450,location = no,resizable = no,scrollbars = no,status = no,toolbar = no,top = 100');
                }
            }
        </script>
        <style type="text/css">
            .img {
                width: 20px;
                height: 30px;
            }
            .c_c {
                background: gray;
            }
        </style>
    </ui:define>
    <ui:define name="content">
        <div style="margin:5px;">
            <h:form id="form">
                <p:growl id="msgs" showDetail="true"/>
                <p:focus for="id"/>
                <p:panel id="ppCondition" header="成本计划登记信息复核" style="width: 100%">
                    <h:panelGrid columns="2" style="width: 100%">
                        <h:panelGrid style="width: 90%">
                            <h:panelGrid>
                                <h:selectOneRadio id="radio" value="#{esPowerAction.strOperType}">
                                    <f:selectItem itemLabel="查询" itemValue="strRadioQry" />
                                    <f:selectItem itemLabel="编辑" itemValue="strRadioEdit" />
                                    <p:ajax update="ppCondition,pdt"
                                            listener="#{esInitCttAction.radioOnClickForPowerAction('Approve','1')}" />
                                </h:selectOneRadio>
                            </h:panelGrid>
                            <h:panelGrid id="pgCondition">
                                <h:panelGrid columns="2" rendered="false">
                                    <h:outputLabel value="所属编号：" for="parentPkid" style="font-weight: bold"/>
                                    <p:inputText id="parentPkid"
                                                 value="#{esInitCttAction.getEsInitCttByPkId(esInitCttAction.itemEsInitCtt.parentPkid).id}"
                                                 readonly="true"
                                                 style="width:127px"/>
                                </h:panelGrid>

                                <h:panelGrid columns="6">
                                    <h:outputLabel value="计划编号：" for="id" style="font-weight: bold"/>
                                    <p:inputText id="id" value="#{esInitCttAction.itemEsInitCtt.id}"
                                                 disabled="#{esInitCttAction.styleModel.disabled_Flag}"
                                                 style="#{esInitCttAction.styleModel.disabled_Style};width:127px"/>

                                    <h:outputLabel value="计划名称：" for="cstplName" style="font-weight: bold"/>
                                    <p:inputText id="cstplName" value="#{esInitCttAction.itemEsInitCtt.name}"
                                                 disabled="#{esInitCttAction.styleModel.disabled_Flag}"
                                                 style="#{esInitCttAction.styleModel.disabled_Style};width:127px"/>

                                    <h:outputLabel value="制定日期：" for="signDate" style="font-weight: bold"/>
                                    <p:inputText id="signDate" value="#{esInitCttAction.itemEsInitCtt.signDate}"
                                                 onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                                 disabled="#{esInitCttAction.styleModel.disabled_Flag}"
                                                 style="#{esInitCttAction.styleModel.disabled_Style};width:127px"/>
                                </h:panelGrid>

                                <h:panelGrid columns="6">
                                    <h:outputLabel value="备注内容：" for="note" style="font-weight: bold"/>
                                    <p:inputTextarea id="note" rows="1" value="#{esInitCttAction.itemEsInitCtt.note}"
                                                     autoResize="false" style="width:127px"/>

                                    <h:outputLabel value="状态标志：" for="statusFlag" style="font-weight: bold"/>
                                    <p:selectOneMenu id="statusFlag" value="#{esInitCttAction.itemEsInitCtt.statusFlag}"
                                                     style="width:131px">
                                        <f:selectItems value="#{esPowerAction.statusFlagList}"/>
                                    </p:selectOneMenu>

                                    <h:outputLabel value="结束标志：" for="endFlag" style="font-weight: bold"/>
                                    <p:selectOneMenu id="endFlag" value="#{esInitCttAction.itemEsInitCtt.endFlag}"
                                                     disabled="#{esInitCttAction.styleModel.disabled_Flag}"
                                                     style="#{esInitCttAction.styleModel.disabled_Style};width:131px">
                                        <f:selectItems value="#{esPowerAction.endFlagList}"/>
                                    </p:selectOneMenu>
                                </h:panelGrid>
                            </h:panelGrid>
                        </h:panelGrid>
                        <h:panelGrid>
                            <p:commandButton id="qryBtn" value="查询"
                                             action="#{esInitCttAction.onQueryAction('1','False')}"
                                             update="pdt,msgs"
                                             rendered="#{esPowerAction.strBtnQryRendered}">
                            </p:commandButton>
                            <p:commandButton id="checkPassBtn" value="批准通过"
                                             action="#{esInitCttAction.onClickForPowerAction('ApprovePass')}"
                                             update="ppCondition,pdt,msgs"
                                             rendered="#{esPowerAction.strBtnEditRendered}">
                            </p:commandButton>
                            <p:commandButton id="checkFailBtn" value="批准未过"
                                             action="#{esInitCttAction.onClickForPowerAction('ApproveFail')}"
                                             update="ppCondition,pdt,msgs"
                                             rendered="#{esPowerAction.strBtnEditRendered}">
                            </p:commandButton>
                            <p:commandButton id="resetBtn" value="重置"
                                             action="#{esInitCttAction.resetAction}"
                                             update="ppCondition,msgs">
                            </p:commandButton>
                        </h:panelGrid>
                    </h:panelGrid>
                </p:panel>

                <p:ajaxStatus style="width:16px;height:16px;">
                    <f:facet name="start">
                        <h:graphicImage value="/images/ajaxloading.gif"/>
                    </f:facet>
                    <f:facet name="complete">
                        <h:outputText value=""/>
                    </f:facet>
                </p:ajaxStatus>

                <p:contextMenu for="pdt">
                    <p:menuitem value="选择" icon="ui-icon-plus"
                                actionListener="#{esInitCttAction.selectRecordAction('Approve','','1')}" update="pdt,msgs,ppCondition">
                    </p:menuitem>
                    <p:menuitem value="详细内容" icon="ui-icon-search"
                                oncomplete="actSelect(DtInitCstplList.selection,'Cstpl_Detail')">
                    </p:menuitem>
                    <p:menuitem value="附件" icon="ui-icon-search"
                                oncomplete="actSelect(DtInitCstplList.selection,'Attachment')" >
                    </p:menuitem>
                </p:contextMenu>
                <p:dataTable id="pdt" style="width:100%;"
                             value="#{esInitCttAction.itemEsInitCttList}"
                             var="record"
                             rowKey="#{record.pkid}"
                             selection="#{esInitCttAction.itemEsInitCttSelected}"
                             selectionMode="single"
                             paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             paginator="true"
                             paginatorPosition="bottom"
                             rows="20"
                             rowsPerPageTemplate="200,100,50,40,30,20,10"
                             emptyMessage="数据记录为空..."
                             widgetVar="DtInitCstplList"
                             rowStyleClass="#{record.statusFlag eq '2' ? null:
                                                 record.statusFlag eq '3' ? null: 'c_c'}">

                    <!--<p:ajax event="rowSelect" listener="#{esInitCttAction.onRowSelect}" update=":form"/>-->


                    <p:column headerText="所属编号" style="width:130px;text-align:center">
                        <h:outputText value="#{esInitCttAction.getEsInitCttByPkId(record.parentPkid).id}"/>
                    </p:column>

                    <p:column headerText="成本计划号" style="width:140px;text-align:center">
                        <h:outputText value="#{record.id}"/>
                    </p:column>

                    <p:column headerText="成本计划名" style="text-align:left">
                        <h:outputText value="#{record.name}"/>
                    </p:column>

                    <p:column headerText="状态标志" style="width:66px;text-align:center">
                        <h:outputText value="#{esPowerAction.getLabelByValueInStatusFlaglist(record.statusFlag)}"/>
                    </p:column>

                    <p:column headerText="原因" style="width:66px;text-align:center">
                        <h:outputText value="#{esPowerAction.getLabelByValueInPreStatusFlaglist(record.preStatusFlag)}"/>
                    </p:column>

                    <p:column headerText="结束标志" style="width:66px;text-align:center">
                        <h:outputText value="#{esPowerAction.getLabelByValueInEndFlagList(record.endFlag)}"/>
                    </p:column>

                        <p:column headerText="制定日期" style="width:66px;text-align:center">
                            <h:outputText value="#{record.signDate}"/>
                        </p:column>

                    <p:column headerText="备注内容" style="text-align:center">
                        <h:outputText value="#{record.note}"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>

</ui:composition>